<?php $post = $this->get('post');?>
<form action="<?php _actionUrl($this)?>" onsubmit="return ajax_form(this)" method="post" onreset="calendar_check_day($('#dfi').k(0))">
<input type="hidden" name="ID" value="<?php _e($post['ID'])?>"/>
<div class="x-list-title"> 
<table height="100%" width="100%" border="0" cellpadding="0">
<tr><td>
<h2>Sửa lịch cá nhân</h2>
</td>
<td align="right">
	<div class="x-list-options">
	</div>
</td>
</tr></table>
</div>
<div class="x-form-container">
<div class="form-message"></div>
<table width="100%" border="0" cellpadding="0" class="x-form">
<tr>
	<td width="100" class="x-form-label">
		Tiêu đề:
	</td>
	<td class="x-form-input">
		<input name="title" type="text" class="x-text" style="width:400px" value="<?php _e($post['title'])?>"/>		
	</td>
</tr>
<tr>
	<td class="x-form-label">
		Ngày thực hiện:
	</td>
	<td class="x-form-input">
		<input autocomplete="off" name="date_start" onclick="date_picker(this,{noTime:true})" onblur="calendar_fill_date_end(this)" type="text" class="x-text x-date" size="10" value="<?php _e(show_date(DATE_FORMAT,$post['date_start']))?>"/>
	</td>
</tr>
<tr>
	<td class="x-form-label">
		Thời gian:
	</td>
	<td class="x-form-input">
		Từ <input autocomplete="off" onclick="time_picker(this)" type="text" class="x-text x-time" size="7" name="time_start" value="<?php _e( $post['time_start'] ? date('H:i',strtotime($post['time_start'])) : '' );?>"/>
		
		 đến <input autocomplete="off" onclick="time_picker(this)" type="text" class="x-text x-time" size="7" name="time_end" value="<?php _e( $post['time_end'] ? date('H:i',strtotime($post['time_end'])): '' );?>"/> 
	</td>
</tr>
<tr>
<td width="100" class="x-form-label">
		Địa điểm:
	</td>
	<td class="x-form-input">
		<input name="place" type="text" class="x-text" style="width:400px" value="<?php _e($post['place']);?>"/>		
	</td>
</tr>
<tr>
	<td class="x-form-label">
		Nội dung:
	</td>
	<td class="x-form-input">
		<textarea class="x-text x-editor" name="content" style="width:610px;height:100px"><?php _e($post['content']);?></textarea>	
	</td>
</tr>
<tr>
	<td class="x-form-label">
		Người tạo:
	</td>
	<td class="x-form-input">
		<?php _e(get_user_link($this->get('user')))?>
	</td>
</tr>
<tr>
	<td class="x-form-label">
		Khách mời:
	</td>
	<td class="x-form-input">
		<div class="x-select-users" x-name="guests[]" x-title="Khách mời">
		<?php foreach( $this->get('guests') as $u):?>	
		<?php if( $u['is_guest'] == 'yes' ):?>
		<span class="item">
			<input type="hidden" name="guests[]" value="<?php _e($u['ID'])?>"><a><?php _e($u['username'])?></a><span class="close">x</span>
		</span>
		<?php endif;?>
		<?php endforeach;?>
		</div>	
	</td>
</tr>
<tr>
	<td class="x-form-label">
		Nhắc nhở:
	</td>
	<td class="x-form-input">
		<input class="x-checkbox" type="checkbox" name="repeat_alert" value="yes"<?php $post['repeat_alert']=='yes' ? _e(' checked') :'' ?>/> Thông báo
		&nbsp;<input type="checkbox" name="repeat_email" value="yes"<?php $post['repeat_email']=='yes' ? _e(' checked') :'' ?>/> Gửi email 
		&nbsp;&nbsp; Trước
		<?php $disabled = $post['repeat_type'] != 'DAY' ? ' disabled ' : ' '; ?>
		<select name="repeat_time_number" class="x-select">
			<option value="0"<?php $post['repeat_time_number']  == '0' ? _e(' selected'):''?>>0</option>
			<option value="1"<?php $post['repeat_time_number']  == '1' ? _e(' selected'):''?>>1</option>
			<option value="2"<?php $post['repeat_time_number']  == '2' ? _e(' selected'):''?>>2</option>
			<option value="5"<?php $post['repeat_time_number']  == '5' ? _e(' selected'):''?>>5</option>
			<option value="10"<?php $post['repeat_time_number'] == '10' ? _e(' selected'):''?>>10</option>
			<option value="30"<?php $post['repeat_time_number'] == '30' ? _e(' selected'):''?>>30</option>
		</select>		
		<select name="repeat_time_unit" class="x-select">
			<option value="1"<?php $post['repeat_time_unit']     == '1' ? _e(' selected'):''?>>phút</option>	
			<option value="60"<?php $post['repeat_time_unit']    == '60' ? _e(' selected'):''?>>giờ</option>	
			<option value="1440"<?php $post['repeat_time_unit']  == '1440' ? _e(' selected'):''?>>ngày</option>	
			<option value="10080"<?php $post['repeat_time_unit'] == '10080' ? _e(' selected'):''?>>tuần</option>	
		</select>		
	</td>
</tr>
<tr>
	<td class="x-form-label" valign="top">
		Tùy chỉnh lặp:
	</td>
	<td class="x-form-input">
		<table cellpadding="10" width="100%">
		<tr>
			<td align="right">
				Kiểu lặp lại:<sup class="hint" title="Lặp hàng tuần: sự kiện lặp vào thứ của ngày đã chọn">[?]</sup> 
			</td>
			<td>
				<input onclick="calendar_check_day(this)" type="radio" name="repeat_type" value="none" checked="checked"/> Không lặp
				<input onclick="calendar_check_day(this)" type="radio" name="repeat_type" value="day"<?php $post['repeat_type'] =='day' ? _e(' checked') :'' ?>/> Hàng ngày
				<input onclick="calendar_check_day(this)" type="radio" name="repeat_type" value="week"<?php $post['repeat_type'] =='week' ? _e(' checked') :'' ?>/> Hàng tuần
				<input onclick="calendar_check_day(this)" type="radio" name="repeat_type" value="month"<?php $post['repeat_type'] =='month' ? _e(' checked') :'' ?>/> Hàng tháng
				<input onclick="calendar_check_day(this)" type="radio" name="repeat_type" value="year"<?php $post['repeat_type'] =='year' ? _e(' checked') :'' ?>/> Hàng năm
			</td>
		</tr><tr>		
			<td align="right">
				Chọn thứ:<sup class="hint" title="Chỉ có hiệu lực nếu chọn kiểu lặp theo ngày">[?]</sup> 
			</td>
			<td id="cday">
				<?php 
					$disabled = $post['repeat_type'] != 'day' ? ' disabled ' : ''; 
					$rp = explode(',',$post['repeat_day']);	
				?>
				<input<?php _e($disabled);?>type="checkbox" name="repeat_day[]" id="dfi" value="1"<?php in_array('1',$rp ) ? _e(' checked') :'' ?>/>Thứ 2
				<input<?php _e($disabled);?>type="checkbox" name="repeat_day[]" value="2"<?php in_array('2',$rp ) ? _e(' checked') :'' ?>/>Thứ 3
				<input<?php _e($disabled);?>type="checkbox" name="repeat_day[]" value="3"<?php in_array('3',$rp ) ? _e(' checked') :'' ?>/>Thứ 4
				<input<?php _e($disabled);?>type="checkbox" name="repeat_day[]" value="4"<?php in_array('4',$rp ) ? _e(' checked') :'' ?>/>Thứ 5
				<input<?php _e($disabled);?>type="checkbox" name="repeat_day[]" value="5"<?php in_array('5',$rp ) ? _e(' checked') :'' ?>/>Thứ 6
				<input<?php _e($disabled);?>type="checkbox" name="repeat_day[]" value="6"<?php in_array('6',$rp ) ? _e(' checked') :'' ?>/>Thứ 7
				<input<?php _e($disabled);?>type="checkbox" name="repeat_day[]" value="0"<?php in_array('0',$rp ) ? _e(' checked') :'' ?>/>Chủ nhật
			</td>
		</tr><tr>		
			<td align="right">
				Ngày kết thúc lặp: <sup class="hint" title="Bỏ trống nếu không có">[?]</sup>
			</td>
			<td id="cday">
				<input name="repeat_date_end" id="d-end" onclick="date_picker(this,{noTime:true});this._focused=true" type="text" class="x-text x-date" size="10" value="<?php _e(show_date(DATE_FORMAT,$post['repeat_date_end']));?>"<?php _e( $post['repeat_type'] == 'none' ? ' disabled ' : '');?>/>						
			</td>						
		</tr>
		</table>									
	</td>
</tr>
<tr>
	<td align="center" colspan="2">
		<?php _e(tpl_button_add('Cập nhật'));?>
		<a href="#Calendar/Index/View?ID=<?php _e($post['ID']);?>" class="x-button x-fresh">Hủy bỏ</a>
	</td>
</tr>
</table></div>
</form>